package com.cong.sort.util;

import com.cong.sort.merge.MergeSort;
import com.cong.sort.select.SelectSort;
import com.cong.sort.shell.ShellSort;

import java.util.Arrays;
import java.util.Random;

/**
 * 校验
 */
public class DataChecker {

    static int[] generateRandomArray(){
        Random random = new Random();
        int[] ints = new int[100000];
        Arrays.parallelSetAll(ints,(i)-> random.nextInt());
        return ints;
    }

    static void check(){
        int[] arr = generateRandomArray();
        int[] arr2 = new int[arr.length];
        System.arraycopy(arr,0,arr2,0,arr.length);
//        Arrays.sort(arr);
        Arrays.parallelSort(arr);
        System.out.println(System.currentTimeMillis());
       // ShellSort.sort2(arr2);
        MergeSort.sort(arr2,0, arr2.length-1);
        System.out.println(System.currentTimeMillis());

        boolean same = true;
        for (int i = 0; i < arr2.length; i++) {
            if (arr[i] !=arr2[i]) same=false;
        }
        System.out.println(same);

    }

    public static void main(String[] args) {
        check();
    }
}
